var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
const fileUpload = require("express-fileupload"); //文件上传
const testRouter = require("./routes/test"); //测试
const userRouter = require("./routes/user"); //用户
const taskRouter = require("./routes/task"); //待办
const chatRouter = require("./routes/chat"); //聊天
const fileRouter = require("./routes/file"); //文件处理
const accountRouter = require("./routes/account"); //记账功能
const collectiontRouter = require("./routes/collection"); //收藏
const allRouter = require("./routes/all"); //综合
const indexRouter = require("./routes/index"); //其他
const utils = require("./server-util/util");
const app = express();

//文件上传
app.use(
	fileUpload({
		createParentPath: true,
	})
);
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use("/", indexRouter);
app.use("/test", testRouter);

app.use("/user", userRouter);
app.use("/task", taskRouter);
app.use("/chat", chatRouter);
app.use("/file", fileRouter); //文件上传
app.use("/account", accountRouter); //记账功能
app.use("/collection", collectiontRouter); //记账功能
app.use("/all", allRouter); //综合
app.use("/doc", express.static("doc"));
app.use("/doc/http", express.static("doc/http"));
// 设置静态文件目录，用于存放 HTML 文件
app.use(express.static(path.join(__dirname, "public")));
app.disable("etag");
module.exports = app;
